<!--注册审核·未处理-->

#include('head.html')
	<style>
		header a{
			height: 44px;
			margin-bottom: 1px;
		}
		header .am-active a{
			color: #f37b1d !important;
		}
	</style>
	</head>
	#if(page>audits.totalPages)
	<script>
		window.location.href="/backstage/audit?con=${search}&page=${audits.totalPages}";
	</script>
	#end
	<body>
		<div class="admin-content-body">
			<div class="am-cf am-padding am-padding-bottom-0">
				<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">注册审核</strong><small></small></div>
			</div>
			<header class="am-topbar" style="background:none;margin-top: -50px;border-color:#eee;">
				<button type="button" class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#doc-topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

				<div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse">
					<ul class="am-nav am-nav-pills am-topbar-nav" style="margin-left:20px;font-size:13px;">
						<li class="am-active"><a>待处理</a></li>
						<li><a href="audit2">已处理</a></li>
					</ul>
				</div>
			</header>


			<div class="am-g">
				<div class="am-u-sm-12 am-u-md-6">
					<div class="am-btn-toolbar">
						<div class="am-btn-group am-btn-group-xs">
							#if(search=="")
							<button type="button" class="am-btn am-btn-default setting"><span class="am-icon-cog"></span> 设置</button>
							#else
							<button type="button" class="am-btn am-btn-default" onclick="location.href='/backstage/audit'">
								<span class="am-icon-chevron-left"></span> 返回
							</button>
							#end
							<button type="button" style="display:none;" class="am-btn am-btn-default am-text-secondary morecheck yesMore"><span class="am-icon-check"></span> 通过</button>
							<button type="button" style="display:none;" class="am-btn am-btn-default am-text-danger morecheck noMore"><span class="am-icon-close"></span> 拒绝</button>
						</div>
					</div>
				</div>
				<div class="am-u-sm-12 am-u-md-3">

				</div>
				<div class="am-u-sm-12 am-u-md-3">
					<div class="am-input-group am-input-group-sm">
						<input type="text" style="color:blue;" placeholder="请输入用户名" id="con" value="${search}" class="am-form-field">
						<span class="am-input-group-btn">
							<button type="button" class="am-btn am-btn-default search" type="button">搜索</button>
					  	</span>
					</div>
				</div>
			</div>
			<div class="am-g">
				<div class="am-u-sm-12">
					<form class="am-form">
						<input type="hidden" name="ids" id="ids">
						<input type="hidden" name="member" id="member">
						<input type="hidden" name="admin" id="admin" value="${admin_name.a_realname}">
						<input type="hidden" name="email" id="email">
						<table class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>
									<th class="table-check"><input class="chooseall" type="checkbox"></th>
									<th class="table-id">ID</th>
									<th class="table-title">用户名</th>
									<th class="table-author am-hide-sm-only">邮箱</th>
									<th class="table-date am-hide-sm-only">注册时间</th>
									<th class="table-set">操作</th>
								</tr>
							</thead>
							<tbody>
                            #for(Users audit:audits.getRows())
								<tr>
									<input type="hidden" id="member1" value="${audit.m_realname}">
									<input type="hidden" id="email1" value="${audit.m_email}">
									<td><input type="checkbox" name="checkbox" value="${audit.m_id}"></td>
									<td>${audit.m_id}</td>
									<td>
										<a onclick="member(${audit.m_id})">${audit.m_realname}</a>
									</td>

									<td class="am-hide-sm-only">
										${audit.m_email}
									</td>
									<td class="am-hide-sm-only">${audit.m_time.substring(0,19)}</td>
									<td>
										<div class="am-btn-toolbar">
											<div class="am-btn-group am-btn-group-xs">
												<button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary yes"><span class="am-icon-check"></span> 通过</button>
												<button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger no"><span class="am-icon-close"></span> 拒绝</button>
											</div>
										</div>
									</td>
								</tr>
                            #end
							#if(audits.getTotalRows()==0)
							<tr><td class="am-hide-sm-only"></td><td></td><td></td><td>暂无记录！</td><td></td><td class="am-hide-sm-only"></td></tr>
							#end
							</tbody>
						</table>
						<div class="am-cf">
							共 ${audits.getTotalRows()} 条记录
                            #if(search!="")(查询结果）
                            #end
							<div class="am-fr">
								<ul class="am-pagination">
									<li class="${audits.isHasPrevPage()  ? '':'am-disabled'}">
										<a href="/backstage/audit?con=${search}&page=${audits.getPrevPage()}">«</a>
									</li>
									#set(j=audits.getPageNum()-(audits.getPageNum()%5!=0?audits.getPageNum()%5:5)+1)
									#for(int i : range(j, (j+4) > audits.totalPages ? audits.totalPages : j+4))
									<li class="${i == audits.pageNum  ? 'am-active':''}">
										<a href="/backstage/audit?con=${search}&page=${i}">${i}</a>
									</li>
									#end
									<li class="${audits.isHasNextPage()  ? '':'am-disabled'}">
										<a href="/backstage/audit?con=${search}&page=${audits.getNextPage()}">»</a>
									</li>
								</ul>
							</div>
						</div>
						<hr>
					</form>
				</div>
			</div>
		</div>
		#include('/backstage/footer.html')
		<script type="text/javascript" src="/static/js/backstage/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="/static/js/backstage/amazeui.min.js"></script>
		<script type="text/javascript" src="/static/js/backstage/choose.js" ></script>
		<script type="text/javascript" src="/static/js/backstage/plugs.js" ></script>

		<script>
		function check(){
			var checkID = [];//定义一个空数组
			var members = [];
			var emails = [];
			$("input[name='checkbox']:checked").each(function(j){//把所有被选中的复选框的值存入数组
				 checkID[j] =$(this).val();
				 members[j] =$(this).parents("tr").find("#member1").val();
				 emails[j] =$(this).parents("tr").find("#email1").val();
			});
			$("#ids").val(checkID);
			$("#member").val(members);
			$("#email").val(emails);
		}

		function member(id){
                $.jq_Panel({
                    title: "用户信息",
                    iframeWidth: 500,
                    iframeHeight: 360,
                    url: "/backstage/lookUser/"+id
                });
			}

		$(function() {

			$(".addon").click(function() {
				window.location.reload();	//刷新
			});

			$(".search").click(function(){
			    window.location.href="/backstage/audit?con="+$("#con").val();
			});

			$(".setting").click(function() {
					$.jq_Panel({
						title: "注册设置",
						iframeWidth: 400,
						iframeHeight: 200,
						url: " regSetting"
					});
			});

			$(".yes").click(function(){
				if(confirm('确定通过审核吗？')){
					$("#ids").val($(this).parents("tr").find("input[name='checkbox']").val());
					$("#member").val($(this).parents("tr").find("#member1").val());
					$("#email").val($(this).parents("tr").find("#email1").val());
			        $.ajax({
                        url:"/backstage/doAudit/1",
                        dataType:"json",
                        type:"post",
                        data:$("form").serialize(),
                        success:function(result){
                           	alert("操作成功！");
							window.location.href=location.href;
                        },
                        error:function(result){
                            console.log(result);
                            alert("系统繁忙！");
                         }
                    });
                }
			});
			$(".no").click(function(){
				if(confirm('确定要拒绝吗？')){
					$("#ids").val($(this).parents("tr").find("input[name='checkbox']").val());
					$("#member").val($(this).parents("tr").find("#member1").val());
					$("#email").val($(this).parents("tr").find("#email1").val());
			        $.ajax({
                        url:"/backstage/doAudit/-1",
                        dataType:"json",
                        type:"post",
                        data:$("form").serialize(),
                        success:function(result){
                           	alert("操作成功！");
							window.location.href=location.href;
                        },
                        error:function(result){
                            console.log(result);
                            alert("系统繁忙！");
                         }
                    });
                }
			});
			$(".yesMore").click(function() {
					if(confirm('确定批量通过吗？')){
						check();
        				$.ajax({
							url:"/backstage/doAudit/1",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert(result.tips+"名用户通过审核！");
								window.location.href=location.href;
							}
						});
					}
			});
			$(".noMore").click(function() {
					if(confirm('确定批量拒绝吗？')){
						check();
        				$.ajax({
							url:"/backstage/doAudit/-1",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert(result.tips+"名用户被拒绝！");
								window.location.href=location.href;
							}
						});
					}
			});

		});
		</script>
	</body>
</html>